<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
	href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script
	src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>

</head>
<body>
	<%
		Connection con = null;
		try {
			request.setCharacterEncoding("utf-8");
			Class.forName("com.mysql.jdbc.Driver");
			String url = "jdbc:mysql://192.168.0.2:3306/namecard";
			String sql = "SELECT * FROM Introduce";
			con = DriverManager.getConnection(url, "elo123123",
					"alflso!@34");

			PreparedStatement ps = con.prepareStatement(sql);
			ResultSet rs = ps.executeQuery();

			//Mobile 테이블 생성
			out.print("<div data-role=\"page\" id=\"pageone\">");
			out.print("<div data-role=\"header\">");
			out.print("<h1>MySQL 테이블 확인</h1>");
			out.print("</div>");
			out.print("<div data-role=\"main\" class=\"ui-content\">");
			out.print("<table data-role=\"table\" data-mode=\"columntoggle\"");
			out.print("class=\"ui-responsive\" id=\"myTable\">");
			out.print("<thead>");
			out.print("<tr>");
			out.print("<th data-priority=\"1\">번호</th>");
			out.print("<th data-priority=\"2\">이름</th>");
			out.print("<th data-priority=\"3\">나이</th>");
			out.print("<th data-priority=\"4\">전화번호</th>");
			out.print("<th data-priority=\"5\">성별</th>");
			out.print("<th data-priority=\"6\">주소</th>");
			out.print("</tr>");
			out.print("</thead>");
			out.print("<tbody>");
			while (rs.next()) {
				out.print("<tr>");
				out.print("<td>" + rs.getInt("id") + "</td>");
				out.print("<td>" + rs.getString("name") + "</td>");
				out.print("<td>" + rs.getString("age") + "</td>");
				out.print("<td>" + rs.getString("tel") + "</td>");
				out.print("<td>" + rs.getString("gender") + "</td>");
				out.print("<td>" + rs.getString("addr") + "</td>");
				out.print("<td style=\"text-align:center\"><a href='UpdateF.jsp?ID="
						+ rs.getInt("ID")
						+ "&name="
						+ rs.getString("name")
						+ "&age="
						+ rs.getString("age")
						+ "&tel="
						+ rs.getString("tel")
						+ "&gender="
						+ rs.getString("gender")
						+ "&addr="
						+ rs.getString("addr") + "'>수정</a></td>");
				out.print("<td style=\"text-align:center\"><a href='Delete.jsp?ID="
						+ rs.getInt("ID") + "'>삭제</a></td>");
			}
			out.print("</tbody>");
			out.print("</table>");
			out.print("</div>");
			out.print("<div data-role=\"footer\"><h1><a href=\"home.jsp\">홈으로</a></h1></div>");
			out.print("</div>");

			ps.close();
		} catch (Exception exc) {
			exc.printStackTrace();
		}
	%>
</body>
</html>